row
  for team in view.teams
    div.matches-column.col-md-5
      table.table.table-bordered.table-condensed.my-matches-table

        tr
          th(colspan=6, style={color: team.primaryColor})
            span(data-i18n="ladder.summary_your") Your
            if !view.level.isType('ladder')
              |#{team.displayName}
              |
            span(data-i18n="ladder.summary_matches") Matches -
            |#{team.wins}
            span(data-i18n="ladder.summary_wins")  Wins,
            |#{team.losses}
            span(data-i18n="ladder.summary_losses")  Losses
            if team.session && team.session.get('submitted')
              a.share-ladder-link-button.pull-right(data-team=team.id)
                span(data-i18n="sharing.share_ladder_link")

        if team.session
          tr
            th(colspan=6)
              .ladder-submission-view(data-session-id=team.session.id)

        if team.scoreHistory
          tr
            th(colspan=6, style={color: team.primaryColor})
              div(class="score-chart-wrapper", data-team-name=team.name, id='score-chart-' + team.name)

        tr
          th(data-i18n="general.result") Result
          th
          th(data-i18n="general.opponent_and_team") Opponent / Team
          th(data-i18n="general.when") When
          th
          th
        for match in team.matches
          tr(class=(match.stale ? "stale " : "") + (match.fresh ? "fresh " : "") + match.state, title=match.simulator)
            td.state-cell
              if match.state === 'win'
                span(data-i18n="general.win").win Win
              if match.state === 'loss'
                span(data-i18n="general.loss").loss Loss
              if match.state === 'tie'
                span(data-i18n="general.tie").tie Tie
            td.code-language-cell(style="background-image: url(/images/common/code_languages/" + match.codeLanguage +  "_icon.png)")
            if match.opTeam
              // our red color: #C71C22, our blue: #0b63bc 
              td.name-cell(style=`color: ${(match.opTeam == 'humans')? '#C71C22' : '#0b63bc'}`)= match.opponentName || view.nameMap[match.opponentID] || "Anonymous"
            else
              td.name-cell= match.opponentName || view.nameMap[match.opponentID] || "Anonymous"
            td.time-cell= match.when
            td.watch-cell
              - var levelID = view.level.get('slug') || view.level.id
              - var league = view.options.league
              - var leagueType = view.options.leagueType
              - var course = view.options.course
              if (match.opTeam && match.opTeam == 'humans') || team.id == 'ogres'
                - var yourTeam = 'ogres'
                - var sessionOne = match.sessionID
                - var sessionTwo = team.session.id
              else
                - var yourTeam = 'humans'
                - var sessionOne = team.session.id
                - var sessionTwo = match.sessionID
              a(href='/play/spectate/' + levelID + '?session-one=' + sessionOne + '&session-two=' + sessionTwo, target='_blank')
                span(data-i18n="play_level.watch_game")
            td.battle-cell
              if view.level.isType('ladder')
                - var yourTeam = 'humans'
              else
                - var yourTeam = match.opTeam == 'humans' ? 'ogres' : 'humans'
              a(href=`/play/level/${levelID}?team=${yourTeam}&opponent=${match.sessionID}` + (league ? `&${leagueType == 'clan' ? 'league=' : ('course=' + course.id + '&course-instance=')}` + league.id : ""))
                if (match.state === 'win')
                  span(data-i18n="ladder.watch_victory") Watch your victory
                else if (view.level.isType('ladder'))
                  span(data-i18n="ladder.fight") Fight!
                else
                  span(data-i18n="ladder.defeat_the") Defeat the
                  |
                  | #{team.otherTeamDisplayName}
 

        if !team.matches.length
          tr
            if team.isRanking
              td(colspan=4).alert.alert-info
                span(data-i18n="ladder.code_being_simulated")
                  | Your new code is being simulated by other players for ranking.
                  | This will refresh as new matches come in.
            else
              td(colspan=4).alert.alert-warning
                span(data-i18n="ladder.no_ranked_matches_pre") No ranked matches for the
                | #{team.name}
                span(data-i18n="ladder.no_ranked_matches_post") team! Play against some competitors and then come back here to get your game ranked.
  .btn.btn-sm.load-more-matches(data-i18n="editor.more") More
